package com.rtz.util;
/**
 * 
 * @author acer
 *
 */
public class PrintfUtil {

	public static void log(Object classObj, Object value) {

		System.out.println(PrintfUtil.getLineInfo(classObj) + " 值:" + value);
	}

	/**
	 * 通过传入类别名获取调用者的行号
	 * 
	 * @param classObj
	 * @return
	 */
	public static String getLineInfo(Object classObj) {

		StackTraceElement[] ste = new Throwable().getStackTrace();
		StackTraceElement stackTraceElement = null;
		for (int i = 0; i < ste.length; i++) {
			stackTraceElement = ste[i];
			if (stackTraceElement != null && (classObj.getClass().getName().equals(stackTraceElement.getClassName()))) {
				break;
			}
		}
		return stackTraceElement.getFileName() + ":Line" + stackTraceElement.getLineNumber();
	}

}
